Add human-readable testo case (and fix bugs)
authorparkrrrr <parkrrrr@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 22 Jul 2004 00:15:55 +0000 (00:15 +0000)
committerparkrrrr <parkrrrr@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 22 Jul 2004 00:15:55 +0000 (00:15 +0000)
gpsbabel/csv_util.c
gpsbabel/reference/human.in [new file with mode: 0644]
gpsbabel/reference/humanread.out [new file with mode: 0644]
gpsbabel/reference/humanread.style [new file with mode: 0644]
gpsbabel/reference/humanwrite.out [new file with mode: 0644]
gpsbabel/reference/humanwrite.style [new file with mode: 0644]
gpsbabel/testo

index 6d26386335524936e0e9c53eca1505b3368f1975..861b8f267156144ac898a8cf77b8439df14240a5 100644 (file)
@@ -337,14 +337,19 @@ human_to_dec( const char *instr, double *outlat, double *outlon )
     while ( cur && *cur ) {
        switch (*cur) {
            case 'n': case 's': case 'N': case 'S':
-               if ( numind && numind < 3 ) {
-                       numind = 0;
+               if ( unk[0] != 999 ) {
+                   numind = 0;
+                   numres = unk;
+                   lat[0] = unk[0];
+                   lat[1] = unk[1];
+                   lat[2] = unk[2];
+                   unk[0] = unk[1] = unk[2] = 999;
+               }
+               else {
+                   numres = lat;
+                   numind = 0;
+                   lat[0] = lat[1] = lat[2] = 999;
                }
-               lat[0] = unk[0];
-               lat[1] = unk[1];
-               lat[2] = unk[2];
-               
-               numres = lat;
                
                if ( *cur == 'n' || *cur == 'N' ) 
                    latsign = 1;
@@ -353,14 +358,19 @@ human_to_dec( const char *instr, double *outlat, double *outlon )
                cur++;
                break;
            case 'w': case 'e': case 'W': case 'E':
-               if ( numind && numind < 3 ) {
-                       numind = 0;
+               if ( unk[0] != 999 ) {
+                   numind = 0;
+                   numres = unk;
+                   lon[0] = unk[0];
+                   lon[1] = unk[1];
+                   lon[2] = unk[2];
+                   unk[0] = unk[1] = unk[2] = 999;
+               }
+               else {
+                   numres = lon;
+                   numind = 0;
+                   lon[0] = lon[1] = lon[2] = 999;
                }
-               lon[0] = unk[0];
-               lon[1] = unk[1];
-               lon[2] = unk[2];
-               
-               numres = lon;
                
                if ( *cur == 'e' || *cur == 'E' ) 
                    lonsign = 1;
@@ -473,7 +483,7 @@ dec_to_human( char *buff, const char *format, const char *dirs, double val )
            sprintf( buff+strlen(buff), subformat );
        }
        formatptr += strlen(subformat);
-    } // end while;
+    } 
     
     xfree(subformat);
 }      
diff --git a/gpsbabel/reference/human.in b/gpsbabel/reference/human.in
new file mode 100644 (file)
index 0000000..1d66537
--- /dev/null
@@ -0,0 +1,7 @@
+W 5 10 15 20 25 30 N
+1°23'45.678"S 1°23'45.678"E
+12d 34.567m N 76d 54.321m E
+N 12.345 W 67.890
+12.345N 67.890W
+12.345N W67.890
+
diff --git a/gpsbabel/reference/humanread.out b/gpsbabel/reference/humanread.out
new file mode 100644 (file)
index 0000000..50093bf
--- /dev/null
@@ -0,0 +1,6 @@
+20.42500       -5.17083
+-1.39602       01.39602
+12.57612       76.90535
+12.34500       -67.89000
+12.34500       -67.89000
+12.34500       -67.89000
diff --git a/gpsbabel/reference/humanread.style b/gpsbabel/reference/humanread.style
new file mode 100644 (file)
index 0000000..28b50c5
--- /dev/null
@@ -0,0 +1,20 @@
+# gpsbabel XCSV style file
+#
+# Format: Human readable read test style
+# Author: Ron Parker
+#   Date: 21 July 2004
+#
+
+DESCRIPTION            Human readable read test style
+EXTENSION              txt
+
+#
+# FILE LAYOUT DEFINITIIONS:
+#
+FIELD_DELIMITER                TAB
+RECORD_DELIMITER       NEWLINE
+
+#
+# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:
+#
+IFIELD LATLON_HUMAN_READABLE, "", ""
diff --git a/gpsbabel/reference/humanwrite.out b/gpsbabel/reference/humanwrite.out
new file mode 100644 (file)
index 0000000..8d47fab
--- /dev/null
@@ -0,0 +1,6 @@
+N 20.425000 W 5.170833 N 020° 25.500' W 005° 10.250'   20.425000 N 5.170833 W  N 20.425000 W 5.170833  N 20 25 30.000000 W 5 10 15.000000      N 20 25 30 W 5 10 15    N 20 W 5        20 degrees 5 degrees
+S 1.396022 E 1.396022  S 001° 23.761' E 001° 23.761'   1.396022 S 1.396022 E   S 1.396022 E 1.396022   S 1 23 45.678000 E 1 23 45.678000       S 1 23 45 E 1 23 45     S 1 E 1 1 degrees 1 degrees
+N 12.576117 E 76.905350        N 012° 34.567' E 076° 54.321'   12.576117 N 76.905350 E N 12.576117 E 76.905350 N 12 34 34.020000 E 76 54 19.260000     N 12 34 34 E 76 54 19   N 12 E 76       12 degrees 76 degrees
+N 12.345000 W 67.890000        N 012° 20.700' W 067° 53.400'   12.345000 N 67.890000 W N 12.345000 W 67.890000 N 12 20 42.000000 W 67 53 24.000000     N 12 20 42 W 67 53 24   N 12 W 67       12 degrees 67 degrees
+N 12.345000 W 67.890000        N 012° 20.700' W 067° 53.400'   12.345000 N 67.890000 W N 12.345000 W 67.890000 N 12 20 42.000000 W 67 53 24.000000     N 12 20 42 W 67 53 24   N 12 W 67       12 degrees 67 degrees
+N 12.345000 W 67.890000        N 012° 20.700' W 067° 53.400'   12.345000 N 67.890000 W N 12.345000 W 67.890000 N 12 20 42.000000 W 67 53 24.000000     N 12 20 42 W 67 53 24   N 12 W 67       12 degrees 67 degrees
diff --git a/gpsbabel/reference/humanwrite.style b/gpsbabel/reference/humanwrite.style
new file mode 100644 (file)
index 0000000..04bf783
--- /dev/null
@@ -0,0 +1,28 @@
+# gpsbabel XCSV style file
+#
+# Format: Human readable write test style
+# Author: Ron Parker
+#   Date: 21 July 2004
+#
+
+DESCRIPTION            Human readable write test style
+EXTENSION              txt
+
+#
+# FILE LAYOUT DEFINITIIONS:
+#
+FIELD_DELIMITER                TAB
+RECORD_DELIMITER       NEWLINE
+
+#
+# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:
+#
+IFIELD LATLON_HUMAN_READABLE, "", "%c %f"
+IFIELD LATLON_HUMAN_READABLE, "", "%c %.3d° %6.3f'" 
+IFIELD LATLON_HUMAN_READABLE, "", "%f %c" 
+IFIELD LATLON_HUMAN_READABLE, "", "%c %f"
+IFIELD LATLON_HUMAN_READABLE, "", "%c %d %d %f"
+IFIELD LATLON_HUMAN_READABLE, "", "%c %d %d %d"
+IFIELD LATLON_HUMAN_READABLE, "", "%c %d"
+IFIELD LATLON_HUMAN_READABLE, "", "%d degrees"
+
index c5dfc4ff8c1bf594b2bcdab66b85979fb5ce983d..ded25c418e9fda4e0a295832818679adf4819505 100755 (executable)
@@ -3,11 +3,24 @@ export GPSBABEL_FREEZE_TIME
 
 PNAME=${PNAME:-./gpsbabel}
 DIFF=${DIFF:-diff}
+OD=${OD:-od -Ax -txC -v}
 
 TMPDIR=/tmp/gpsbabel.$$
 mkdir -p $TMPDIR
 trap "rm -fr $TMPDIR" 0 1 2 3 15
 
+bincompare()
+{
+       rm -f ${TMPDIR}/bc1
+        rm -f ${TMPDIR}/bc2
+        ${OD} $1 >${TMPDIR}/bc1 
+        ${OD} $2 >${TMPDIR}/bc2
+        ${DIFF} ${TMPDIR}/bc1 ${TMPDIR}/bc2 || {
+               echo ERROR binary comparing $*
+                exit 1
+       }
+}
+
 compare()
 {
        ${DIFF} $* ||  {
@@ -162,6 +175,12 @@ ${PNAME} -i magnav -f reference/magnav.pdb -o gpsutil -F ${TMPDIR}/magnavt.gpu
 compare ${TMPDIR}/magnavt.gpu ${TMPDIR}/magnav.gpu
 compare reference/gu.wpt ${TMPDIR}/magnav.gpu
 
+rm -f ${TMPDIR}/magnav.pdb
+${PNAME} -i geo -f geocaching.loc -o magnav -F ${TMPDIR}/magnav.pdb
+bincompare ${TMPDIR}/magnav.pdb reference/magnav.pdb
+
+
+
 # GPSPilot Tracker for PalmOS
 # This test is eerily similar to the NAV Companion test.  In fact, the 
 # converted reference file (magnavr.gpu) is identical.
@@ -501,6 +520,17 @@ ${DIFF} ${TMPDIR}/gpl1.gpx ${TMPDIR}/gpl2.gpx
 #
 rm -f ${TMPDIR}/netstumbler.mps
 ${PNAME} -i netstumbler -f reference/netstumbler.txt -o mapsource -F ${TMPDIR}/netstumbler.mps
-compare ${TMPDIR}/netstumbler.mps reference/netstumbler.mps
+bincompare ${TMPDIR}/netstumbler.mps reference/netstumbler.mps
+
+#
+# XCSV "human readable" tests
+#
+rm -f ${TMPDIR}/humanread.out
+${PNAME} -i xcsv,style=reference/humanread.style -f reference/human.in -o arc -F ${TMPDIR}/humanread.out
+compare ${TMPDIR}/humanread.out reference/humanread.out
+
+rm -f ${TMPDIR}/humanwrite.out
+${PNAME} -i xcsv,style=reference/humanread.style -f reference/human.in -o xcsv,style=reference/humanwrite.style -F ${TMPDIR}/humanwrite.out
+compare ${TMPDIR}/humanwrite.out reference/humanwrite.out
 
 exit 0